#ifndef TEST_COMMON_H
#define TEST_COMMON_H


#include "cuda_runtime.h"
#include <cuda.h>

template <typename T>
void dumpArrayDataToFile(T * dataIn, int num, const char * strFileName);

void dumpFftResultToFile(float * fftData,int len, const char * strFileName);

#define TEST_TIMES 20
typedef float2 Complex_local;
void dumpComplexDataArrayToFile(Complex_local *dataIn, int len, char*strFileName);
void dumpComplexDataMatrixToFile(Complex_local *dataIn, int height, int width, const char*strFileName);

template <typename T>
void dumpArrayDataToFile(T * dataIn, int num, const char * strFileName)
{
	FILE * fp = fopen(strFileName, "w");

	char strToWrite[1024];
	strToWrite[0] = '\0';
	unsigned int sum = 0;
	for (int i = 0; i < num; i++)
	{
		sprintf(strToWrite, "%s %s", strToWrite, to_string(dataIn[i]).c_str());
		sum = sum + dataIn[i];
		if (i % 20 == 19)
		{
			sprintf(strToWrite, "%s\n", strToWrite);
		}
		if (strlen(strToWrite) >= 900)
		{
			fwrite(strToWrite, strlen(strToWrite), 1, fp);
			memset(strToWrite, 0, 1024);
		}
	}
	if (strlen(strToWrite))
	{
		fwrite(strToWrite, strlen(strToWrite), 1, fp);
	}
	//printf("sum is %d\n", sum);
	fclose(fp);
}

double getCpuClock(void);

#endif